#[cfg(test)]
mod test  {
    use crate::topic::Topic;
    use crate::simple_consumer::*;
    use crate::simple_producer::*;
    #[test]
    fn test_producer_consume(){
        let mut topic = Topic::new("topic_name", "."); //TODO: move to singleton

        let log = "key:value";
        let bytes = log.as_bytes();
        //produce log
        {
            let mut sp = SimpleProducer::new("producer", &mut topic);

            assert_eq!(bytes.len(), sp.produce(bytes).unwrap());
        }
        // consume it
        {
            let mut sc = SimpleConsumer::new("consumer", &mut topic);

            let mut buf = [23; 100];
            let read_bytes = sc.consume(&mut buf).unwrap();
            assert_eq!(bytes.len(), read_bytes);

            assert_eq!(bytes, &buf[0..read_bytes]);
        }
    }
}
